<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link href="/JG/Content/jquery/weui/style/weui.min.css" rel="stylesheet" />
    <link href="/JG/Content/jquery/jquery-weui/css/jquery-weui.min.css" rel="stylesheet" />
    <link href="/JG/Content/css/bootstrap.min.css" rel="stylesheet" />
    <link href="/JG/Content/css/bootstrap-select.css" rel="stylesheet" />
    <link href="/JG/Content/css/bootstrap-select.min.css" rel="stylesheet" />
    <link href="/JG/Content/css/Global.css" rel="stylesheet" />
    <link rel="stylesheet" href="/JG/Content/css/AntennaeTaskDetail.css?v=1">
    <script src="/JG/Content/LocalConfigs.js"></script>
    <script src="/JG/Content/LocalUserInfo.js"></script>

    <title>生产确认</title>
    <style>
        [v-cloak] {
            display: none;
        }
    </style>
</head>

<body>
    <header class="header">
        <div class="empty"></div>
        <div class="header_title">
            <a href="javascript:;">生产确认</a>
        </div>
        <div class="item item2">
            <div class="user_img" onclick="javascript:location.href='/JG/Home/Index.html'">
                <span class="back"><img src="/JG/Content/images/return.png" alt=""></span>
            </div>
        </div>
    </header>

    <div id="MainPage" class="MainPage" v-cloak>
        <table class="table">
            <tr>
                <td style="text-align:right;border-right:1px solid #ddd">产品SN码</td>
                <td style="border-right:1px solid #ddd">{{FormData.SCJP_TM}}</td>
                <td style="text-align:right;border-right:1px solid #ddd">产品编码</td>
                <td style="border-right:1px solid #ddd">{{FormData.SCJP_CPBH}}</td>
            </tr>
            <tr>
                <td style="text-align:right;border-right:1px solid #ddd">产品名称</td>
                <td style="border-right:1px solid #ddd">{{FormData.SCJP_CPMC}}</td>
                <td style="text-align:right;border-right:1px solid #ddd">生产状态</td>
                <td style="border-right:1px solid #ddd">{{FormData.SCJP_RWZT_NAME}}</td>
            </tr>
            <tr>
                <td style="text-align:right;border-right:1px solid #ddd">开工时间</td>
                <td style="border-right:1px solid #ddd">{{FormData.SCJP_KSSJ}}</td>
                <td style="text-align:right;border-right:1px solid #ddd">完工时间</td>
                <td style="border-right:1px solid #ddd">{{FormData.SCJP_JSSJ}}</td>
            </tr>
            <tr>
                <td style="text-align:right;border-right:1px solid #ddd">生产工序</td>
                <td style="border-right:1px solid #ddd">{{FormData.SCJP_GXMC}}</td>
                <td style="text-align:right;border-right:1px solid #ddd">生产员</td>
                <td style="border-right:1px solid #ddd">{{FormData.SCJP_SCY}}</td>
            </tr>
            <tr>
                <td colspan="4" style="text-align:center;">确认说明</td>
            </tr>
            <tr>
                <td colspan="4" style="text-align:center;">
                    <textarea name="" v-model="FormData.SCJP_QRSM" id="SCJP_QRSM" cols="15" rows="5"
                        style="width: 100%;"></textarea></td>
            </tr>
            <tr>
                <td colspan="4">
                    <div class="weui-gallery" id="gallery">
                        <span class="weui-gallery__img" id="galleryImg"></span>
                        <div class="weui-gallery__opr">
                            <a href="javascript:" class="weui-gallery__del">
                                <i class="weui-icon-delete weui-icon_gallery-delete"></i>
                            </a>
                        </div>
                    </div>
                    <div class="weui-cells weui-cells_form">
                        <div class="weui-cell">
                            <div class="weui-cell__bd">
                                <div class="weui-uploader">
                                    <div class="weui-uploader__hd">
                                        <p class="weui-uploader__title">上传学生头像相片</p>
                                        <div class="weui-uploader__info"></div>
                                    </div>
                                    <div class="weui-uploader__bd">
                                        <ul class="weui-uploader__files" id="uploaderFiles"></ul>
                                        <div class="weui-uploader__input-box" v-if="CurrImgNum<MaxImgNum">
                                            <input type="hidden" name="StudentImg" v-model="FormData.StudentImg" />
                                            <input type="hidden" name="StudentImg" v-model="FormData.ImgID" />
                                            <input id="uploaderInput" class="weui-uploader__input" type="file"
                                                accept="image/*" multiple="" v-on:change="ImgUploader">
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </td>
            </tr>
            <tr>
                <td colspan="2" style="text-align: center"><button class="btn btn-success">取消</button> </td>
                <td colspan="2" style="text-align: center"><button class="btn btn-success"
                        @click="ConfirmedFinish">确认完成</button></td>
            </tr>
        </table>
    </div>
    <script src="/JG/Content/jquery/jquery-3.2.1.min.js"></script>
    <script src="/JG/Content/jquery/jquery-weui/js/jquery-weui.min.js"></script>
    <script src="/JG/Content/bootstrap.min.js"></script>
    <script src="/JG/Content/bootstrap-select.min.js"></script>
    <script src="/JG/Content/bootstrap/bootbox/bootbox.min.js"></script>
    <script src="/JG/Content/bootstrap/bootbox/bootbox.locales.min.js"></script>
    <script src="/JG/Content/Utils.js"></script>
    <script src="/JG/Content/vue-v2.34.js"></script>
    <script type="text/javascript">
        //body赋值滚动条
        var SelImgIndex; //第几张图片
        window.onload = function () {
            var BodyWidth = $(window).width();
            var BodyHeight = $(window).height();
        }
        $(function () {
            $gallery = $("#gallery");
            $galleryImg = $("#galleryImg");
            $uploaderInput = $("#uploaderInput");
            $uploaderFiles = $("#uploaderFiles");
            $gallery__del = $(".weui-gallery__del");

            $uploaderFiles.on("click", "li", function () {
                SelImgIndex = $(this).index();
                $galleryImg.attr("style", this.getAttribute("style"));
                $gallery.fadeIn(100);
            });
            $gallery.on("click", function () {
                $uploaderFiles.find("li")
                $gallery.fadeOut(100);
            });

            $gallery__del.click(function () { //这部分刚才放错地方了，放到$(function(){})外面去了
                event.stopPropagation();
                $.confirm("确认要删除该图片吗？", "删除提示", function () {
                    var li = $uploaderFiles.find("li").eq(SelImgIndex);
                    if (li.length > 0) {
                        vm.FormData.ImgID = "";
                        vm.FormData.StudentImg = "";
                    }
                    li.remove();
                    var num = $('.weui-uploader__file').length;
                    vm.CurrImgNum = num;
                    $gallery.fadeOut(100);
                });
            });
        });
    </script>
    <script type="text/javascript">
        var vmPage = new Vue({
            el: "#MainPage",
            data: {
                ID: $.getUrlParam("ID"),
                CurrImgNum: "",
                MaxImgNum: "",
                FormData: {
                    ImgID: "",
                    StudentImg: ""
                }
            },
            mounted: function () {
                var currSelf = this;
                $(".weui-uploader__input-box").show();
                $("#uploaderFiles").empty();
                if (currSelf.ID) {
                    $.showLoading();
                    $.ajax({
                        type: "post",
                        url: LocalConfig.SrvPath + "/jgmes/jgmesScrwAction!getCrrScrwScqk.action",
                        data: {
                            mac: LocalUserInfo.GetUserInfo().Mac,
                            userCode: LocalUserInfo.GetUserInfo().UserCode,
                            "prodLineCode": LocalUserInfo.GetUserInfo().ProductionLineCode,
                            "JGMES_PB_SCJP_ID": currSelf.ID
                        },
                        datatype: "json",
                        success: function (result) {
                            var data = JSON.parse(result);
                            var ret = ReturnData(data);
                            if (ret.IsSuccess) {
                                currSelf.FormData = ret.Data;
                            } else if (!ret.Data) {
                                var showMsg = "未能找到产品相关的产品SN码";
                                $.toptip(showMsg, "warning");
                            }
                        },
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                            console.error(textStatus);
                            $.alert("发生异常," + errorThrown);
                        }, complete: function () {
                            $.hideLoading();
                        }
                    });
                }
            },
            methods: {
                ConfirmedFinish: function () {
                    var currSelf = this;
                    bootbox.confirm({
                        message: "是否确认完成么？", buttons: {
                            confirm: {
                                label: '是',
                                className: 'btn-success',
                            },
                            cancel: {
                                label: '否',
                                className: 'btn-danger'
                            }
                        }, callback: function (result) {
                            if (result) {
                                $.showLoading();

                                $.ajax({
                                    type: "post",
                                    url: LocalConfig.SrvPath + "/jgmes/jgmesScrwAction!doConfirmSN.action",
                                    data: {
                                        "userCode": LocalUserInfo.GetUserInfo().UserCode,
                                        "mac": LocalUserInfo.GetUserInfo().Mac,
                                        "prodLineCode": LocalUserInfo.GetUserInfo().ProductionLineCode,
                                        "JGMES_PB_SCJP_ID": currSelf.FormData.JGMES_PB_SCJP_ID,
                                        "qrr": LocalUserInfo.GetUserInfo().UserName,
                                        "Remark": currSelf.FormData.SCJP_QRSM,
                                        "file": currSelf.FormData.SCJP_FJ
                                    },
                                    dataType: "json",
                                    success: function (ret) {
                                        var retData = ReturnData(ret);
                                        if (retData.IsSuccess) {

                                        } else {

                                        }
                                    },
                                    error: function (xhr, status, error) {
                                        console.error(status);
                                        $.alert("请求失败!");
                                    }, complete: function () {
                                        $.hideLoading();
                                    }
                                });
                            }
                        }
                    });
                }
            }
        })
    </script>

</html>